package com.aizuda.easy.security.exp.impl;

import com.aizuda.easy.security.exp.IErrorCode;

import java.text.MessageFormat;


public class BasicException extends RuntimeException {

    private Integer code;
    private String msg;
    private Object[] args;

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public Object[] getArgs() {
        return args;
    }

    private BasicException(){
    }

    public BasicException(Integer code,String msg,Object... args){
        super(MessageFormat.format(msg,args));
        this.code = code;
        this.msg = MessageFormat.format(msg,args);
        this.args = args;
    }

    public BasicException(IErrorCode iErrorCode, Object... args){
        super(MessageFormat.format(iErrorCode.getMsg(),args));
        this.code = iErrorCode.getCode();
        this.msg = MessageFormat.format(iErrorCode.getMsg(),args);
        this.args = args;
    }


}
